<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{- |
This module provides a low-level API to the line history stored in the @InputT@ monad transformer.


For most application, it should suffice to instead use the following @Settings@ flags:

  * @autoAddHistory@: add nonblank lines to the command history ('True' by default).

  * @historyFile@: read/write the history to a file before and after the line input session.

If you do want custom history behavior, you may need to disable the above default setting(s).

-}</span><span>
</span><span id="line-14"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Console.Haskeline.History</span><span class="hs-special">(</span><span>
</span><span id="line-15"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier">History</span></a></span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#emptyHistory"><span class="hs-identifier">emptyHistory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistory"><span class="hs-identifier">addHistory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistoryUnlessConsecutiveDupe"><span class="hs-identifier">addHistoryUnlessConsecutiveDupe</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistoryRemovingAllDupes"><span class="hs-identifier">addHistoryRemovingAllDupes</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#historyLines"><span class="hs-identifier">historyLines</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#readHistory"><span class="hs-identifier">readHistory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#writeHistory"><span class="hs-identifier">writeHistory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#stifleHistory"><span class="hs-identifier">stifleHistory</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>                        </span><span class="annot"><a href="System.Console.Haskeline.History.html#stifleAmount"><span class="hs-identifier">stifleAmount</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>                        </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.html#"><span class="hs-identifier">Data.Sequence</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Seq</span></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.html#"><span class="hs-identifier">Data.Sequence</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#Seq"><span class="hs-identifier">Seq</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#%3C%7C"><span class="hs-operator">(&lt;|)</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#ViewL"><span class="hs-identifier">ViewL</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#ViewR"><span class="hs-identifier">ViewR</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#viewl"><span class="hs-identifier">viewl</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#viewr"><span class="hs-identifier">viewr</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier">toList</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../directory/src/System.Directory.html#"><span class="hs-identifier">System.Directory</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../directory/src/System.Directory.html#doesFileExist"><span class="hs-identifier">doesFileExist</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IO</span></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="System.Console.Haskeline.Recover.html"><span class="hs-identifier">System.Console.Haskeline.Recover</span></a></span><span>
</span><span id="line-37"></span><span>
</span><span id="line-38"></span><span class="hs-keyword">data</span><span> </span><span id="History"><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-var">History</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="History"><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-var">History</span></a></span></span><span> </span><span class="hs-special">{</span><span id="histLines"><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#Seq"><span class="hs-identifier hs-type">Seq</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-39"></span><span>                        </span><span id="stifleAmt"><span class="annot"><span class="annottext">History -&gt; Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var hs-var">stifleAmt</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span class="hs-special">}</span><span>
</span><span id="line-40"></span><span>                    </span><span class="hs-comment">-- stored in reverse</span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-comment">-- | The maximum number of lines stored in the history.  If 'Nothing', the history storage is unlimited.</span><span>
</span><span id="line-43"></span><span class="annot"><a href="System.Console.Haskeline.History.html#stifleAmount"><span class="hs-identifier hs-type">stifleAmount</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-44"></span><span id="stifleAmount"><span class="annot"><span class="annottext">stifleAmount :: History -&gt; Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmount"><span class="hs-identifier hs-var hs-var">stifleAmount</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">History -&gt; Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var hs-var">stifleAmt</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679093895"><span id="local-6989586621679093898"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-47"></span><span>    </span><span id="local-6989586621679093887"><span class="annot"><span class="annottext">show :: History -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var hs-var hs-var hs-var">show</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; String
forall a. Show a =&gt; a -&gt; String
</span><a href="../../base/src/GHC.Show.html#show"><span class="hs-identifier hs-var">show</span></a></span><span> </span><span class="annot"><span class="annottext">(Seq String -&gt; String)
-&gt; (History -&gt; Seq String) -&gt; History -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="annot"><a href="System.Console.Haskeline.History.html#emptyHistory"><span class="hs-identifier hs-type">emptyHistory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-50"></span><span id="emptyHistory"><span class="annot"><span class="annottext">emptyHistory :: History
</span><a href="System.Console.Haskeline.History.html#emptyHistory"><span class="hs-identifier hs-var hs-var">emptyHistory</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; Maybe Int -&gt; History
</span><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-var">History</span></a></span><span> </span><span class="annot"><span class="annottext">Seq String
forall a. Seq a
</span><a href="../../containers/src/Data.Sequence.Internal.html#empty"><span class="hs-identifier hs-var">Seq.empty</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span class="hs-comment">-- | The input lines stored in the history (newest first)</span><span>
</span><span id="line-53"></span><span class="annot"><a href="System.Console.Haskeline.History.html#historyLines"><span class="hs-identifier hs-type">historyLines</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-54"></span><span id="historyLines"><span class="annot"><span class="annottext">historyLines :: History -&gt; [String]
</span><a href="System.Console.Haskeline.History.html#historyLines"><span class="hs-identifier hs-var hs-var">historyLines</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; [String]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span> </span><span class="annot"><span class="annottext">(Seq String -&gt; [String])
-&gt; (History -&gt; Seq String) -&gt; History -&gt; [String]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="hs-comment">-- | Reads the line input history from the given file.  Returns</span><span>
</span><span id="line-57"></span><span class="hs-comment">-- 'emptyHistory' if the file does not exist or could not be read.</span><span>
</span><span id="line-58"></span><span class="annot"><a href="System.Console.Haskeline.History.html#readHistory"><span class="hs-identifier hs-type">readHistory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-59"></span><span id="readHistory"><span class="annot"><span class="annottext">readHistory :: String -&gt; IO History
</span><a href="System.Console.Haskeline.History.html#readHistory"><span class="hs-identifier hs-var hs-var">readHistory</span></a></span></span><span> </span><span id="local-6989586621679093882"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093882"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IOException -&gt; IO History) -&gt; IO History -&gt; IO History
forall e a. Exception e =&gt; (e -&gt; IO a) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#handle"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier hs-type">IOException</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">History -&gt; IO History
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="System.Console.Haskeline.History.html#emptyHistory"><span class="hs-identifier hs-var">emptyHistory</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO History -&gt; IO History) -&gt; IO History -&gt; IO History
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-60"></span><span>    </span><span id="local-6989586621679093880"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679093880"><span class="hs-identifier hs-var">exists</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO Bool
</span><a href="../../directory/src/System.Directory.html#doesFileExist"><span class="hs-identifier hs-var">doesFileExist</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093882"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-61"></span><span>    </span><span id="local-6989586621679093879"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093879"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679093880"><span class="hs-identifier hs-var">exists</span></a></span><span>
</span><span id="line-62"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
</span><a href="System.Console.Haskeline.History.html#readUTF8File"><span class="hs-identifier hs-var">readUTF8File</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093882"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-63"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span>
</span><span id="line-64"></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093879"><span class="hs-identifier hs-var">contents</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- force file closed</span><span>
</span><span id="line-65"></span><span>    </span><span class="annot"><span class="annottext">History -&gt; IO History
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">History :: Seq String -&gt; Maybe Int -&gt; History
</span><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">histLines :: Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var">histLines</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; Seq String
forall a. [a] -&gt; Seq a
</span><a href="../../containers/src/Data.Sequence.Internal.html#fromList"><span class="hs-identifier hs-var">Seq.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; Seq String) -&gt; [String] -&gt; Seq String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; [String]
</span><a href="../../base/src/Data.OldList.html#lines"><span class="hs-identifier hs-var">lines</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093879"><span class="hs-identifier hs-var">contents</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-66"></span><span>                    </span><span class="annot"><span class="annottext">stifleAmt :: Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var">stifleAmt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-comment">-- | Writes the line history to the given file.  If there is an</span><span>
</span><span id="line-69"></span><span class="hs-comment">-- error when writing the file, it will be ignored.</span><span>
</span><span id="line-70"></span><span class="annot"><a href="System.Console.Haskeline.History.html#writeHistory"><span class="hs-identifier hs-type">writeHistory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span id="writeHistory"><span class="annot"><span class="annottext">writeHistory :: String -&gt; History -&gt; IO ()
</span><a href="System.Console.Haskeline.History.html#writeHistory"><span class="hs-identifier hs-var hs-var">writeHistory</span></a></span></span><span> </span><span id="local-6989586621679093873"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093873"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(IOException -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall e a. Exception e =&gt; (e -&gt; IO a) -&gt; IO a -&gt; IO a
</span><a href="../../base/src/Control.Exception.Base.html#handle"><span class="hs-identifier hs-var">handle</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-special">(</span><span class="annot"><span class="annottext">IOException
</span><span class="hs-identifier">_</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../base/src/GHC.IO.Exception.html#IOException"><span class="hs-identifier hs-type">IOException</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-72"></span><span>        </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; (History -&gt; IO ()) -&gt; History -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; IO ()
</span><a href="System.Console.Haskeline.History.html#writeUTF8File"><span class="hs-identifier hs-var">writeUTF8File</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093873"><span class="hs-identifier hs-var">file</span></a></span><span>
</span><span id="line-73"></span><span>        </span><span class="annot"><span class="annottext">(String -&gt; IO ()) -&gt; (History -&gt; String) -&gt; History -&gt; IO ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">[String] -&gt; String
</span><a href="../../base/src/Data.OldList.html#unlines"><span class="hs-identifier hs-var">unlines</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; String) -&gt; (History -&gt; [String]) -&gt; History -&gt; String
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">History -&gt; [String]
</span><a href="System.Console.Haskeline.History.html#historyLines"><span class="hs-identifier hs-var">historyLines</span></a></span><span> </span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-comment">-- | Limit the number of lines stored in the history.</span><span>
</span><span id="line-76"></span><span class="annot"><a href="System.Console.Haskeline.History.html#stifleHistory"><span class="hs-identifier hs-type">stifleHistory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-77"></span><span id="stifleHistory"><span class="annot"><span class="annottext">stifleHistory :: Maybe Int -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#stifleHistory"><span class="hs-identifier hs-var hs-var">stifleHistory</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span id="local-6989586621679093870"><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093870"><span class="hs-identifier hs-var">hist</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093870"><span class="hs-identifier hs-var">hist</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">stifleAmt :: Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var">stifleAmt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-78"></span><span class="annot"><a href="System.Console.Haskeline.History.html#stifleHistory"><span class="hs-identifier hs-var">stifleHistory</span></a></span><span> </span><span id="local-6989586621679093869"><span class="annot"><span class="annottext">a :: Maybe Int
</span><a href="#local-6989586621679093869"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679093868"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679093868"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679093867"><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093867"><span class="hs-identifier hs-var">hist</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">History :: Seq String -&gt; Maybe Int -&gt; History
</span><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">histLines :: Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var">histLines</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; Seq String
forall {a}. Seq a -&gt; Seq a
</span><a href="#local-6989586621679093866"><span class="hs-identifier hs-var">stifleFnc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093867"><span class="hs-identifier hs-var">hist</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-79"></span><span>                                </span><span class="annot"><span class="annottext">stifleAmt :: Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var">stifleAmt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621679093869"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-80"></span><span>    </span><span class="hs-keyword">where</span><span>
</span><span id="line-81"></span><span>        </span><span id="local-6989586621679093866"><span class="annot"><span class="annottext">stifleFnc :: Seq a -&gt; Seq a
</span><a href="#local-6989586621679093866"><span class="hs-identifier hs-var hs-var">stifleFnc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679093868"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; Int
forall a. Seq a -&gt; Int
</span><a href="../../containers/src/Data.Sequence.Internal.html#length"><span class="hs-identifier hs-var">Seq.length</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093867"><span class="hs-identifier hs-var">hist</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span>                        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Seq a -&gt; Seq a
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-83"></span><span>                        </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Seq a
forall a. [a] -&gt; Seq a
</span><a href="../../containers/src/Data.Sequence.Internal.html#fromList"><span class="hs-identifier hs-var">Seq.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([a] -&gt; Seq a) -&gt; (Seq a -&gt; [a]) -&gt; Seq a -&gt; Seq a
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; [a] -&gt; [a]
forall a. Int -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#take"><span class="hs-identifier hs-var">take</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679093868"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">([a] -&gt; [a]) -&gt; (Seq a -&gt; [a]) -&gt; Seq a -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Seq a -&gt; [a]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistory"><span class="hs-identifier hs-type">addHistory</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-86"></span><span id="addHistory"><span class="annot"><span class="annottext">addHistory :: String -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#addHistory"><span class="hs-identifier hs-var hs-var">addHistory</span></a></span></span><span> </span><span id="local-6989586621679093858"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093858"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621679093857"><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093857"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093857"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">histLines :: Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var">histLines</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Int -&gt; Seq String -&gt; Seq String
forall a. Maybe Int -&gt; Seq a -&gt; Seq a
</span><a href="System.Console.Haskeline.History.html#maybeDropLast"><span class="hs-identifier hs-var">maybeDropLast</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">History -&gt; Maybe Int
</span><a href="System.Console.Haskeline.History.html#stifleAmt"><span class="hs-identifier hs-var hs-var">stifleAmt</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093857"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093858"><span class="hs-identifier hs-var">s</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; Seq String -&gt; Seq String
forall a. a -&gt; Seq a -&gt; Seq a
</span><a href="../../containers/src/Data.Sequence.Internal.html#%3C%7C"><span class="hs-operator hs-var">&lt;|</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093857"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">}</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="hs-comment">-- If the sequence is too big, drop the last entry.</span><span>
</span><span id="line-89"></span><span id="local-6989586621679093965"><span class="annot"><a href="System.Console.Haskeline.History.html#maybeDropLast"><span class="hs-identifier hs-type">maybeDropLast</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#Seq"><span class="hs-identifier hs-type">Seq</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679093965"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#Seq"><span class="hs-identifier hs-type">Seq</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679093965"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-90"></span><span id="maybeDropLast"><span class="annot"><span class="annottext">maybeDropLast :: forall a. Maybe Int -&gt; Seq a -&gt; Seq a
</span><a href="System.Console.Haskeline.History.html#maybeDropLast"><span class="hs-identifier hs-var hs-var">maybeDropLast</span></a></span></span><span> </span><span id="local-6989586621679093855"><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621679093855"><span class="hs-identifier hs-var">maxAmt</span></a></span></span><span> </span><span id="local-6989586621679093854"><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093854"><span class="hs-identifier hs-var">hs</span></a></span></span><span>
</span><span id="line-91"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679093853"><span class="hs-identifier hs-var">rightSize</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093854"><span class="hs-identifier hs-var">hs</span></a></span><span>
</span><span id="line-92"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Seq a -&gt; ViewR a
forall a. Seq a -&gt; ViewR a
</span><a href="../../containers/src/Data.Sequence.Internal.html#viewr"><span class="hs-identifier hs-var">viewr</span></a></span><span> </span><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093854"><span class="hs-identifier hs-var">hs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-93"></span><span>                    </span><span class="annot"><span class="annottext">ViewR a
</span><a href="../../containers/src/Data.Sequence.Internal.html#EmptyR"><span class="hs-identifier hs-var">EmptyR</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093854"><span class="hs-identifier hs-var">hs</span></a></span><span>
</span><span id="line-94"></span><span>                    </span><span id="local-6989586621679093851"><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093851"><span class="hs-identifier hs-var">hs'</span></a></span></span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#%3A%3E"><span class="hs-operator hs-type">:&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093851"><span class="hs-identifier hs-var">hs'</span></a></span><span>
</span><span id="line-95"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-96"></span><span>    </span><span id="local-6989586621679093853"><span class="annot"><span class="annottext">rightSize :: Bool
</span><a href="#local-6989586621679093853"><span class="hs-identifier hs-var hs-var">rightSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; (Int -&gt; Bool) -&gt; Maybe Int -&gt; Bool
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Seq a -&gt; Int
forall a. Seq a -&gt; Int
</span><a href="../../containers/src/Data.Sequence.Internal.html#length"><span class="hs-identifier hs-var">Seq.length</span></a></span><span> </span><span class="annot"><span class="annottext">Seq a
</span><a href="#local-6989586621679093854"><span class="hs-identifier hs-var">hs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe Int
</span><a href="#local-6989586621679093855"><span class="hs-identifier hs-var">maxAmt</span></a></span><span>
</span><span id="line-97"></span><span>
</span><span id="line-98"></span><span class="hs-comment">-- | Add a line to the history unless it matches the previously recorded line.</span><span>
</span><span id="line-99"></span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistoryUnlessConsecutiveDupe"><span class="hs-identifier hs-type">addHistoryUnlessConsecutiveDupe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-100"></span><span id="addHistoryUnlessConsecutiveDupe"><span class="annot"><span class="annottext">addHistoryUnlessConsecutiveDupe :: String -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#addHistoryUnlessConsecutiveDupe"><span class="hs-identifier hs-var hs-var">addHistoryUnlessConsecutiveDupe</span></a></span></span><span> </span><span id="local-6989586621679093847"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093847"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679093846"><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093846"><span class="hs-identifier hs-var">hs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; ViewL String
forall a. Seq a -&gt; ViewL a
</span><a href="../../containers/src/Data.Sequence.Internal.html#viewl"><span class="hs-identifier hs-var">viewl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093846"><span class="hs-identifier hs-var">hs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-101"></span><span>    </span><span id="local-6989586621679093845"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093845"><span class="hs-identifier hs-var">h1</span></a></span></span><span> </span><span class="annot"><a href="../../containers/src/Data.Sequence.Internal.html#%3A%3C"><span class="hs-operator hs-type">:&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Seq String
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093847"><span class="hs-identifier hs-var">h</span></a></span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093845"><span class="hs-identifier hs-var">h1</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093846"><span class="hs-identifier hs-var">hs</span></a></span><span>
</span><span id="line-102"></span><span>    </span><span class="annot"><span class="annottext">ViewL String
</span><span class="hs-identifier">_</span></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#addHistory"><span class="hs-identifier hs-var">addHistory</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093847"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093846"><span class="hs-identifier hs-var">hs</span></a></span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-comment">-- | Add a line to the history, and remove all previous entries which are the </span><span>
</span><span id="line-105"></span><span class="hs-comment">-- same as it.</span><span>
</span><span id="line-106"></span><span class="annot"><a href="System.Console.Haskeline.History.html#addHistoryRemovingAllDupes"><span class="hs-identifier hs-type">addHistoryRemovingAllDupes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="System.Console.Haskeline.History.html#History"><span class="hs-identifier hs-type">History</span></a></span><span>
</span><span id="line-107"></span><span id="addHistoryRemovingAllDupes"><span class="annot"><span class="annottext">addHistoryRemovingAllDupes :: String -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#addHistoryRemovingAllDupes"><span class="hs-identifier hs-var hs-var">addHistoryRemovingAllDupes</span></a></span></span><span> </span><span id="local-6989586621679093843"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093843"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span id="local-6989586621679093842"><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093842"><span class="hs-identifier hs-var">hs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; History -&gt; History
</span><a href="System.Console.Haskeline.History.html#addHistory"><span class="hs-identifier hs-var">addHistory</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093843"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093842"><span class="hs-identifier hs-var">hs</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">histLines :: Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var">histLines</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Seq String
</span><a href="#local-6989586621679093841"><span class="hs-identifier hs-var">filteredHS</span></a></span><span class="hs-special">}</span><span>
</span><span id="line-108"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-109"></span><span>    </span><span id="local-6989586621679093841"><span class="annot"><span class="annottext">filteredHS :: Seq String
</span><a href="#local-6989586621679093841"><span class="hs-identifier hs-var hs-var">filteredHS</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[String] -&gt; Seq String
forall a. [a] -&gt; Seq a
</span><a href="../../containers/src/Data.Sequence.Internal.html#fromList"><span class="hs-identifier hs-var">Seq.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">([String] -&gt; Seq String) -&gt; [String] -&gt; Seq String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; Bool) -&gt; [String] -&gt; [String]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093843"><span class="hs-identifier hs-var">h</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([String] -&gt; [String]) -&gt; [String] -&gt; [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Seq String -&gt; [String]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span> </span><span class="annot"><span class="annottext">(Seq String -&gt; [String]) -&gt; Seq String -&gt; [String]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">History -&gt; Seq String
</span><a href="System.Console.Haskeline.History.html#histLines"><span class="hs-identifier hs-var hs-var">histLines</span></a></span><span> </span><span class="annot"><span class="annottext">History
</span><a href="#local-6989586621679093842"><span class="hs-identifier hs-var">hs</span></a></span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-comment">---------</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- UTF-8 file I/O, for old versions of GHC</span><span>
</span><span id="line-113"></span><span>
</span><span id="line-114"></span><span class="annot"><a href="System.Console.Haskeline.History.html#readUTF8File"><span class="hs-identifier hs-type">readUTF8File</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-115"></span><span id="readUTF8File"><span class="annot"><span class="annottext">readUTF8File :: String -&gt; IO String
</span><a href="System.Console.Haskeline.History.html#readUTF8File"><span class="hs-identifier hs-var hs-var">readUTF8File</span></a></span></span><span> </span><span id="local-6989586621679093836"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093836"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-116"></span><span>    </span><span id="local-6989586621679093835"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093835"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-var">IO.openFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093836"><span class="hs-identifier hs-var">file</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#ReadMode"><span class="hs-identifier hs-var">IO.ReadMode</span></a></span><span>
</span><span id="line-117"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var">IO.hSetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093835"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">(TextEncoding -&gt; IO ()) -&gt; TextEncoding -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding -&gt; TextEncoding
</span><a href="System.Console.Haskeline.Recover.html#transliterateFailure"><span class="hs-identifier hs-var">transliterateFailure</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="../../base/src/GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-var">IO.utf8</span></a></span><span>
</span><span id="line-118"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; NewlineMode -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetNewlineMode"><span class="hs-identifier hs-var">IO.hSetNewlineMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093835"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier hs-var">IO.noNewlineTranslation</span></a></span><span>
</span><span id="line-119"></span><span>    </span><span id="local-6989586621679093827"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093827"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; IO String
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hGetContents"><span class="hs-identifier hs-var">IO.hGetContents</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093835"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-120"></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO Int
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093827"><span class="hs-identifier hs-var">contents</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">IO.hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093835"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-122"></span><span>    </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093827"><span class="hs-identifier hs-var">contents</span></a></span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="annot"><a href="System.Console.Haskeline.History.html#writeUTF8File"><span class="hs-identifier hs-type">writeUTF8File</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#FilePath"><span class="hs-identifier hs-type">FilePath</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-125"></span><span id="writeUTF8File"><span class="annot"><span class="annottext">writeUTF8File :: String -&gt; String -&gt; IO ()
</span><a href="System.Console.Haskeline.History.html#writeUTF8File"><span class="hs-identifier hs-var hs-var">writeUTF8File</span></a></span></span><span> </span><span id="local-6989586621679093824"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093824"><span class="hs-identifier hs-var">file</span></a></span></span><span> </span><span id="local-6989586621679093823"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093823"><span class="hs-identifier hs-var">contents</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-126"></span><span>    </span><span id="local-6989586621679093822"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093822"><span class="hs-identifier hs-var">h</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">String -&gt; IOMode -&gt; IO Handle
</span><a href="../../base/src/GHC.IO.StdHandles.html#openFile"><span class="hs-identifier hs-var">IO.openFile</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093824"><span class="hs-identifier hs-var">file</span></a></span><span> </span><span class="annot"><span class="annottext">IOMode
</span><a href="../../base/src/GHC.IO.IOMode.html#WriteMode"><span class="hs-identifier hs-var">IO.WriteMode</span></a></span><span>
</span><span id="line-127"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; TextEncoding -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetEncoding"><span class="hs-identifier hs-var">IO.hSetEncoding</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093822"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">TextEncoding
</span><a href="../../base/src/GHC.IO.Encoding.html#utf8"><span class="hs-identifier hs-var">IO.utf8</span></a></span><span>
</span><span id="line-128"></span><span>    </span><span class="hs-comment">-- Write a file which is portable between systems.</span><span>
</span><span id="line-129"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; NewlineMode -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hSetNewlineMode"><span class="hs-identifier hs-var">IO.hSetNewlineMode</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093822"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">NewlineMode
</span><a href="../../base/src/GHC.IO.Handle.Types.html#noNewlineTranslation"><span class="hs-identifier hs-var">IO.noNewlineTranslation</span></a></span><span>
</span><span id="line-130"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; String -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutStr"><span class="hs-identifier hs-var">IO.hPutStr</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093822"><span class="hs-identifier hs-var">h</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679093823"><span class="hs-identifier hs-var">contents</span></a></span><span>
</span><span id="line-131"></span><span>    </span><span class="annot"><span class="annottext">Handle -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.html#hClose"><span class="hs-identifier hs-var">IO.hClose</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621679093822"><span class="hs-identifier hs-var">h</span></a></span><span>
</span><span id="line-132"></span></pre></body></html>